/*
 * url:跳转地址
 */
function signIn(url) {
	var state = $.webSignState();
	if(state.code == "00"){
		layer.msg("已经登录", {icon: 0});
	}else{
		window.location.href = "signin.html";
	}
}

function signUp(url) {
	var data = $.webSignState();
	if(data.code !='00'){
		layer.msg("您未登录", {icon: 0});
	}else{
		layer.confirm('您确定要退出吗?', 
		function(index){
			$.ajax({
				url: $.httpRootPath() + '/api/web/log/logout',
				type: 'GET',
				dataType: 'json',
				timeout: 15000,
				success: function(reply) {
					if(reply.code == "00") {
						layer.msg(reply.msg, {icon: 1});
					}else{
						layer.msg("未知错误", {icon: 1});
					}
				},
				error: function(e) {
					layer.msg("未知错误", {icon: 0});
					return false;
				}
			})
  			layer.close(index);
  			location.reload()
		});
	}
}

function goWhenInState(url) {
	var data = $.webSignState();
	if(data.code =='00'){
		window.location.href = url;
	}else{
		layer.confirm(data.msg, 
		function(index){
  			window.location.href = "signin.html";
		});
	}
};

function goHref(url) {
	window.location.href = url;
}

function getRelation(oid){
	var real = "-1"
	$.ajax({
		url: $.httpRootPath() + '/api/web/manager/getRelation',
		type: 'GET',
		dataType: 'json',
		data: {"oid": oid},
		timeout: 15000,
		async: false,
		success: function(reply) {
			if(reply.code == "00") {
				console.log(reply.msg+" "+ reply.data);
				real = reply.data;
			}
		},
		error: function(e) {
			layer.msg("未知错误", {icon: 0});
		}
	});
	return real;
};



